package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class COS extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject instanceof Number)
      return FunctionHelper.parsePrimitiveDouble(Math.cos(((Number)localObject).doubleValue()));
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "COS(number): 返回一个角度的余弦值。\nNumber:以弧度表示的需要求余弦值的角度。\n备注:\n    要把一个角度转换成弧度值，将角度乘于PI()/180。\n    COS(n*2*PI()+number)=COS(number)（其中n为整数，number从-pi到pi）。\n示例:\nCOS(0.5)等于0.877582562。\nCOS(30*PI()/180)等于0.866025404。";
  }

  public String getEN()
  {
    return "COS(number): Returns the cosine of the given angle.\nNumber is the angle in radians for which you want the cosine.\n\nRemarks:\n1. If the angle is in degrees, multiply it by PI()/180 or use the COS function to convert it to radians.\n2. COS(n*2*PI()+number)=COS(number), n is an integer, number is between -pi and pi.\n\nExample:\n   COS(0.5)=0.877582562\n   COS(30*PI()/180)=0.866025404";
  }
}